package com.liuceng.zen.service;

import com.liuceng.zen.mapper.FrontSelfOperateCreativeMapper;
import com.liuceng.zen.pojo.domain.FrontSelfOperateCreative;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by yanwen on 16-11-3.
 * FrontSelfOperateCreativeService :
 */
@Service
public class FrontSelfOperateCreativeService extends BaseService<FrontSelfOperateCreative> {
    @Autowired
    private FrontSelfOperateCreativeMapper frontSelfOperateCreativeMapper;

    @Transactional
    public Integer delete(Integer memberId,Integer frontSelfCreatetiveId){
        Map<String,Object> map=new HashMap<>();
        map.put("memberId",memberId);
        map.put("id",frontSelfCreatetiveId);
        map.put("deletedAt",new Date());
        frontSelfOperateCreativeMapper.updateByParams(map);
        return frontSelfCreatetiveId;
    }

    public List<FrontSelfOperateCreative> findCreatives(Integer frontAdGroupId,Integer frontSelfOperateCreativeId){
        Map<String,Object> map = new HashMap<>();
        map.put("frontAdGroupId",frontAdGroupId);
        map.put("frontSelfOperateCreativeId",frontSelfOperateCreativeId);
        return frontSelfOperateCreativeMapper.findCreatives(map);
    }

    public List<FrontSelfOperateCreative> checkPcAndMobile(Integer memberId,Integer sitesetType){
        Map<String,Object> map = new HashMap<>();
        map.put("memberId",memberId);
        map.put("sitesetType",sitesetType);
        return frontSelfOperateCreativeMapper.findCreatives(map);
    }

    public List<FrontSelfOperateCreative> findCreativeByIds(List<Integer> ids){
        Map<String,Object> map = new HashMap<>();
        map.put("ids",ids);
        return frontSelfOperateCreativeMapper.findCreativeByIds(map);
    }
}
